---
id: "return-decorator"
keywords: ["return", "decorator"]
name: "@return"
summary: "This is the `@return` decorator."
category: "decorators"
---

The `@return` decorator is used to control how `null` and `undefined` values are converted to `option` types in ReScript.

### Example

<CodeTab labels={["ReScript", "JS Output"]}>

```res
type element
type dom

@send @return(nullable)
external getElementById: (dom, string) => option<element> = "getElementById"

let test = dom => {
  let elem = dom->getElementById("haha")
  switch elem {
  | None => 1
  | Some(_) => 2
  }
}
```

```js
function test(dom) {
  var elem = dom.getElementById("haha");
  if (elem == null) {
    return 1;
  } else {
    return 2;
  }
}
```

</CodeTab>

### References

- [Bind to JS function](../docs/manual/bind-to-js-function.mdx)
